// 定义数据
const state = {
  nav: [], // 左侧导航栏的数据
  isCollapse: false, // 是否收缩左侧导航栏 false为展开 true为收缩
  asideTitle: [
    {
      authName: '数据统计',
      path: '/areaDetail/data',
      activeIndex: 0
    }
  ], // 存储点击左侧导航栏后的导航名，作为标题显示头
  crumbs: [
    '数据统计', '数据统计'
  ], // 存储面包屑
  activeIndex: 0, // 当前活跃的标题下标
  count: 0 // 下标增值变量
}

// 缓存数据
const getters = {
  Navs: state => {
    return state.nav
  },
  CollapseState: state => {
    return state.isCollapse
  },
  AsideTitle: state => {
    return state.asideTitle
  },
  Active: state => {
    return state.activeIndex
  },
  Count: state => {
    return state.count
  },
  Crumbs: state => {
    return state.crumbs
  }
}

// 修改数据
const mutations = {
  setCollapse (state, payload) {
    state.isCollapse = payload
  },
  setAside (state, values) {
    state.asideTitle.push(values)
  },
  delOrAddAside (state, value) {
    state.asideTitle = value
  },
  setActiveIndex (state, value) {
    state.activeIndex = value
  },
  setCount (state, value) {
    state.count = value
  },
  setCrumbs (state, crumbs) {
    state.crumbs = crumbs
  },
  setNav (state, values) {
    state.nav = values
  }
}

// 复杂的操作（调用接口）
const actions = {
  setNavs (context, nav) {
    context.commit('setNav', nav)
  }
}

// 导出
export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
